PRGE Outcome

Column

BRIEF Client-Parent Responses

BRIEF Parent Responses

CLASS

PCSS

HIT

Column

Client Demographics

Client Demographics
Sex Age Prior Concussions History of Depression or Anxiety
Female 16 3 No

PRGE Repeated

Column

Status Tracking

Perceived Effort

Perceived Strategy Helpfulness

FALO Outcome

Column

BRIEF Self Report

BRIEF Parent Report

CLASS

PCSS

PCSS Results
Cognitive Symptoms
PCSS Question Response
Feeling Slow Pre 0
Feeling Slow Post NA
Feeling Foggy Pre 0
Feeling Foggy Post NA
Difficulty Concentrating Pre 4
Difficulty Concentrating Post NA
Difficulty Remembering Pre 3
Difficulty Remembering Post NA

HIT

Column

Client Demographics

Client Demographics
Sex Age Prior Concussions History of Depression or Anxiety
Male 18 4 No

FALO Repeated

Column

Status Tracking 1

Phone Strategy Use

Perceived Effectiveness

Status Tracking 2

Planner Use

Planner Helpfulness

Time Block Use

Planner Helpfulness

DRKAT Outcome

Column

BRIEF

CLASS

PCSS

HIT

Column

Client Demographics

Client Demographics
Sex Age Prior Concussions History of Depression or Anxiety
Female 19 4 No

DRKAT Repeated

Column

Status Tracking

---
title: "Pilot Data 2020"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: menu
    source_code: embed
    vertical_layout: scroll
    theme: spacelab
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(rio)
library(here)
library(colorblindr)
library(gghighlight)
library(forcats)
library(ggrepel)
library(gt)
library(knitr)
library(kableExtra)
library(reactable)
library(plotly)

opts_chunk$set(echo = FALSE,
               fig.width = 5,
               fig.height = 6)

theme_set(theme_minimal(base_size = 8))

outcome <- import(here("data", "client_data_outcome.sav"),
               setclass = "tbl_df") %>% 
  characterize() %>% 
  janitor::clean_names() 

rm_prge <- import(here("data", "repeated_measures_prge.sav"),
               setclass = "tbl_df") %>% 
  characterize() %>% 
  janitor::clean_names() 

head(outcome)
head(rm_prge)

rm_drkat <- import(here("data", "drkat_rm.csv"),
                   setclass = "tbl_df") %>% 
  janitor::clean_names()

head(rm_drkat)

brief_data <- import(here("data", "brief_pilot_data.xlsx"),
                     setclass = "tbl_df") %>% 
  janitor::clean_names()

head(brief_data)

falo_rm <- import(here("data", "falo_rm.xlsx"),
                  setclass = "tbl_df") %>% 
  janitor::clean_names()
```

# PRGE Outcome

Column {.tabset data-width=650}
-----------------------------------------------------------------------

```{r outcome measures data organization, include=FALSE}
head(outcome)

brief <- outcome %>% 
  filter(client == "PRGE") %>% 
  select(1, c(16:31))

brief_prge <- brief %>% 
  select(client, brief_eri_pre_self, brief_eri_post_self, brief_eri_pre_inf, brief_eri_post_inf)

brief_tidy <- brief_prge %>% 
  rename("Self Pre ERI" = brief_eri_pre_self,
         "Self Post ERI" = brief_eri_post_self,
         "Parent Pre ERI" = brief_eri_pre_inf,
         "Parent Post ERI" = brief_eri_post_inf) %>% 
  pivot_longer(
    cols = c(2:5),
    names_to = "measure",
    values_to = "score"
  )

prge_brief_parent <- brief_data %>% 
  filter(client == "PRGE") %>% 
  select(client, 8, 9, 16, 17) %>% 
  rename("SM Pre" = self_monitor_pre_parent,
         "SM Post" = self_monitor_post_parent,
         "EC Pre" = emotional_control_pre_parent,
         "EC Post" = emotional_control_post_parent) %>% 
  pivot_longer(
    cols = c(2:5),
    names_to = "measure",
    values_to = "score"
  )

prge_parent <- c("SM Pre",
         "SM Post",
         "EC Pre",
         "EC Post")

class <- outcome %>% 
  filter(client == "PRGE") %>% 
  select(client, class_total_pre, class_total_post) %>% 
  rename("Pre Score" = class_total_pre,
         "Post Score" = class_total_post)

class_tidy <- class %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )


symptoms <- outcome %>% 
  filter(client == "PRGE") %>% 
  select(1, c(6:13)) %>% 
  rename("Feeling Slow Pre" = pcss_pre_feeling_slow,
         "Feeling Slow Post" = pcss_post_feeling_slow,
         "Feeling Foggy Pre" = pcss_pre_feeling_foggy,
         "Feeling Foggy Post" = pcss_post_feeling_foggy,
         "Difficulty Concentrating Pre" = pcss_pre_difficulty_concentrating,
         "Difficulty Concentrating Post" = pcss_post_difficulty_concentrating, 
         "Difficulty Remembering Pre" = pcss_pre_difficulty_remembering,
         "Difficulty Remembering Post" = pcss_post_difficulty_remembering) %>% 
  pivot_longer(
    cols = c(2:9),
    names_to = "measure",
    values_to = "score"
  )

hit <- outcome %>% 
  filter(client == "PRGE") %>% 
  select(client, hit_pre, hit_post) %>% 
  rename("Pre Score" = hit_pre,
         "Post Score" = hit_post) %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )
```

```{r outcome plots, include=FALSE}
#geom_rect(aes(xmin = -Inf, xmax = Inf, ymin = 65, ymax = 100),
            #fill = "lightgreen") + #insert before geom_col 

prge_brief <- c("Self Pre ERI",
                "Self Post ERI",
                "Parent Pre ERI",
                "Parent Post ERI")
              
class_positions <- c("Pre Score", "Post Score")

pcss_positions <- c("Difficulty Remembering Post",
                    "Difficulty Remembering Pre",
                    "Difficulty Concentrating Post",
                     "Difficulty Concentrating Pre",
                     "Feeling Foggy Post",
                    "Feeling Foggy Pre",
                    "Feeling Slow Post",
                    "Feeling Slow Pre")

hit_positions <- c("Pre Score", "Post Score")

p1 <- ggplot(brief_tidy, aes(measure, score)) +
  geom_hline(yintercept = 65, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = prge_brief) +
  scale_y_continuous(limits = c(0, 100),
                     breaks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold"),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "T-score",
       title = "BRIEF Scores",
       subtitle = "Emotion Regulation Index",
       caption = "T-scores Above 65 are Clinically Significant") 

prge_parent_graph <- ggplot(prge_brief_parent, aes(measure, score)) +
  geom_hline(yintercept = 65, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = prge_parent) +
  scale_y_continuous(limits = c(0, 100),
                     breaks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold"),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "T-score",
       title = "BRIEF Scores",
       subtitle = "Parent Responses to the Self-Monitor and Emotional Control Scales",
       caption = "T-scores Above 65 are Clinically Significant") 

prge_parent_graph 
  
p1

p2 <- ggplot(class_tidy, aes(measure, score)) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = class_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "CLASS Scores") 
 p2


p3 <- ggplot(symptoms, aes(measure, score)) +
  geom_hline(yintercept = 30, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = pcss_positions) +
  scale_y_continuous(limits = c(0, 6),
                     breaks = c(0, 1, 2, 3, 4, 5, 6)) + 
  coord_flip() +
  geom_text(aes(measure, score, label = score),
            nudge_y = -0.5,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "PCSS Results",
       subtitle = "Cognitive Symptoms",
       caption = "0 = No Symptoms\n 3 = Moderate Symptoms\n 6 = Severe Symptoms") 

p3

p3a <- ggplot(hit, aes(measure, score)) +
  geom_hline(yintercept = 50, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = hit_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) + 
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "HIT Results",
       caption = "Scores of 50 or Greater Suggest Headaches Impact Daily Functioning") 

p3a
```

### BRIEF Client-Parent Responses
```{r prge brief, include=TRUE}
p1

```

### BRIEF Parent Responses
```{r prge parent brief, include=TRUE}
prge_parent_graph
```

### CLASS
```{r prge class, include=TRUE}
p2
```


### PCSS

```{r prge pcss, include=TRUE}
p3
```


### HIT

```{r prge hit, include=TRUE}
p3a
```


Column {data-width=350}
-----------------------------------------------------------------------

### Client Demographics

```{r, include=FALSE}
head(outcome)

demo_prge <- outcome %>% 
  filter(client == "PRGE") %>% 
  select(2:5)
  
head(demo_prge)

prge_table <- demo_prge %>% 
  gt() %>% 
  cols_label(sex = "Sex",
             age = "Age",
             prev_mtbi = "Prior Concussions",
             hx_depression = "History of Depression or Anxiety") %>% 
  cols_align(align = "center", columns = vars(sex, age, prev_mtbi, hx_depression)) %>% 
  tab_header(title = "Client Demographics")
  
prge_table
```

```{r prge table, include=TRUE}
prge_table
```

# PRGE Repeated 

Column {.tabset data-width=650}
-----------------------------------------------------------------------

### Status Tracking

```{r repeated measures data cleaning, include=FALSE}

head(rm_prge)

track <- rm_prge %>% 
  select(session, status)

p4 <- ggplot(track, aes(session, status)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 6),
                     breaks = c(1, 2, 3, 4, 5, 6)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Times Required to Reread Content",
       title = "Status Tracking Goal") 

p4


effort_data <- rm_prge %>% 
  select(session, effort)

p5 <- ggplot(effort_data, aes(session, effort)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Perceived Effort During Reading",
       title = "Perceived Effort While Reading",
       caption = "1 = No Effort\n 2 = A little Effort\n 3 = Somewhat Effortful\n 4 = Quite Effortful\n 5 = Extremely Effortful") 

p5

helpfulness <- rm_prge %>% 
  select(session, help)

p6 <- ggplot(helpfulness, aes(session, help)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Perceived Helpfulness",
       title = "Perceived Helpfulness of Reading Strategies",
       caption = "1 = Not Helpful at All\n 2 = Not Helpful\n 3 = Somewhat Helpful\n 4 = Helpful\n 5 = Very Helpful") 

p6
```


```{r status, include=TRUE}
p4
```

### Perceived Effort

```{r effort, include=TRUE, fig.align="left"}
p5
```

### Perceived Strategy Helpfulness 

```{r helpfulness, include=TRUE, fig.align="left"}
p6
```


# FALO Outcome

Column {.tabset data-width=650}
-----------------------------------------------------------------------

```{r falo measures data organization, include=FALSE}
head(outcome)

falo <- outcome %>% 
  filter(client == "FALO")

falo_brief_self <- brief_data %>% 
  filter(client == "FALO") %>% 
  select(client,
         working_memory_pre_self, 
         working_memory_post_self,
         plan_organize_pre_sr,
         plan_organize_post_sr,
         task_monitor_pre_sr,
         task_monitor_post_sr) %>% 
  rename("WM Pre" = working_memory_pre_self,
         "WM Post" = working_memory_post_self,
         "PO Pre" = plan_organize_pre_sr,
         "PO Post" = plan_organize_post_sr,
         "TM Pre" = task_monitor_pre_sr,
         "TM Post" = task_monitor_post_sr) %>% 
  pivot_longer(
    cols = c(2:7),
    names_to = "measure",
    values_to = "score"
  ) 


falo_sr_brief <- c("WM Pre",
         "WM Post",
         "PO Pre",
         "PO Post",
         "TM Pre",
         "TM Post")
  
falo_sr_plot <- ggplot(falo_brief_self, aes(measure, score)) +
  geom_hline(yintercept = 65, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = falo_sr_brief) +
  scale_y_continuous(limits = c(0, 100),
                     breaks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold"),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "T-score",
       title = "BRIEF Scores",
       subtitle = "Working Memory, Plan/Organize, and Task Monitoring Scales",
       caption = "T-scores Above 65 are Clinically Significant") 

falo_sr_plot


falo_brief_parent <- brief_data %>% 
  filter(client == "FALO") %>% 
  select(client,
         working_memory_pre_parent, 
         working_memory_post_parent,
         plan_organize_pre_parent,
         plan_organize_post_parent,
         task_monitor_pre_parent,
         task_monitor_post_parent) %>% 
  rename("WM Pre" = working_memory_pre_parent,
         "WM Post" = working_memory_post_parent,
         "PO Pre" = plan_organize_pre_parent,
         "PO Post" = plan_organize_post_parent,
         "TM Pre" = task_monitor_pre_parent,
         "TM Post" = task_monitor_post_parent) %>% 
  pivot_longer(
    cols = c(2:7),
    names_to = "measure",
    values_to = "score"
  ) 

falo_parent_plot <- ggplot(falo_brief_parent, aes(measure, score)) +
  geom_hline(yintercept = 65, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = falo_sr_brief) +
  scale_y_continuous(limits = c(0, 100),
                     breaks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold"),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "T-score",
       title = "BRIEF Scores",
       subtitle = "Working Memory, Plan/Organize, and Task Monitoring Scales",
       caption = "T-scores Above 65 are Clinically Significant") 

falo_parent_plot

class_falo <- falo %>% 
  select(client, class_total_pre, class_total_post) %>% 
  rename("Pre Score" = class_total_pre,
         "Post Score" = class_total_post) %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )

pcss_falo <- falo %>% 
  select(1, c(6:13)) %>% 
  rename("Feeling Slow Pre" = pcss_pre_feeling_slow,
         "Feeling Slow Post" = pcss_post_feeling_slow,
         "Feeling Foggy Pre" = pcss_pre_feeling_foggy,
         "Feeling Foggy Post" = pcss_post_feeling_foggy,
         "Difficulty Concentrating Pre" = pcss_pre_difficulty_concentrating,
         "Difficulty Concentrating Post" = pcss_post_difficulty_concentrating, 
         "Difficulty Remembering Pre" = pcss_pre_difficulty_remembering,
         "Difficulty Remembering Post" = pcss_post_difficulty_remembering) %>% 
  pivot_longer(
    cols = c(2:9),
    names_to = "measure",
    values_to = "score"
  )

hit_falo <- falo %>% 
  select(client, hit_pre, hit_post) %>% 
  rename("Pre Score" = hit_pre,
         "Post Score" = hit_post) %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )
```

```{r falo plots, include=FALSE}

p8 <- ggplot(class_falo, aes(measure, score)) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = class_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "CLASS Scores") 
 p8


p9 <- ggplot(pcss_falo, aes(measure, score)) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = pcss_positions) +
  scale_y_continuous(limits = c(0, 6),
                     breaks = c(0, 1, 2, 3, 4, 5, 6)) + 
  geom_text(aes(measure, score, label = score),
            nudge_y = -1,
            color = "white") +
  coord_flip() +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "PCSS Results",
       subtitle = "Cognitive Symptoms",
       caption = "0 = No Symptoms\n 3 = Moderate Symptoms\n 6 = Severe Symptoms") 

p9

falo_pcss_table <- pcss_falo %>% 
  select(-client) %>% 
  gt() %>% 
  cols_label(measure = "PCSS Question",
             score = "Response") %>% 
  cols_align(align = "left", columns = vars(measure)) %>% 
  cols_align(align = "center", columns = vars(score)) %>% 
  tab_header(title = "PCSS Results",
             subtitle = "Cognitive Symptoms")

falo_pcss_table

falo_reactable <- pcss_falo %>% 
  select(-client) %>% 
  rename("PCSS Question" = measure,
         "Response" = score) %>% 
  reactable()

falo_reactable



p10 <- ggplot(hit_falo, aes(measure, score)) +
  geom_hline(yintercept = 50, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = hit_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) + 
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "HIT Results",
       caption = "Scores of 50 or Greater Suggest Headaches Significantly Impact Daily Functioning") 

p10
```

### BRIEF Self Report

```{r falo brief, include=TRUE, fig.width=6}
falo_sr_plot
```

### BRIEF Parent Report

```{r falo brief parent, include=TRUE, fig.width=6}
falo_parent_plot
```

### CLASS

```{r falo class, include=TRUE, fig.width=6}
p8
```

### PCSS

```{r falo pcss, include=TRUE}
falo_pcss_table
```

### HIT

```{r falo hit, include=TRUE}
p10
```

Column {data-width=350}
-----------------------------------------------------------------------

### Client Demographics

```{r, include=FALSE}
head(outcome)

demo_falo <- outcome %>% 
  filter(client == "FALO") %>% 
  select(2:5)
  
head(demo_falo)

falo_table <- demo_falo %>% 
  gt() %>% 
  cols_label(sex = "Sex",
             age = "Age",
             prev_mtbi = "Prior Concussions",
             hx_depression = "History of Depression or Anxiety") %>% 
  cols_align(align = "center", columns = vars(sex, age, prev_mtbi, hx_depression)) %>% 
  tab_header(title = "Client Demographics")
  
falo_table
```

```{r falo table, include=TRUE}
falo_table
```

# FALO Repeated 

Column {.tabset data-width=650}
-----------------------------------------------------------------------

### Status Tracking 1

```{r falo repeated measures data cleaning, include=FALSE}

head(falo_rm)

falo_status_1 <- falo_rm %>% 
  select(session, status_1)

falo_status_1_plot <- ggplot(falo_status_1, aes(session, status_1)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 7),
                     breaks = c(0, 1, 2, 3, 4, 5, 6, 7)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Nights Per Week Gone to Bed Prior to 3:00 AM",
       title = "Status Tracking Goal 1") 

falo_status_1_plot

phone_falo <- falo_rm %>% 
  select(session, num_nights)

phone_falo_graph <- ggplot(phone_falo, aes(session, num_nights)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 7),
                     breaks = c(0, 1, 2, 3, 4, 5, 6, 7)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Nights Per Week Implementing No-Phone Strategy",
       title = "No Phone Strategy",
       subtitle = "To be implemented 1:00-7:00 AM") 

phone_falo_graph

falo_effect <- falo_rm %>% 
  select(session, effect)

falo_effect_graph <- ggplot(falo_effect, aes(session, effect)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Perceived Effectiveness",
       title = "Perceived Effectiveness of No Phone Strategy",
       caption = "1 = Not Effective at All\n 2 = Not Effective\n 3 = Somewhat Effective\n 4 = Effective\n 5 = Very Effective") 

falo_effect_graph

falo_status_2 <- falo_rm %>% 
  select(session, status_2)

falo_status_2_plot <- ggplot(falo_status_2, aes(session, status_2)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(0, 1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Missing Assignments per Week",
       title = "Status Tracking Goal 2") 

falo_status_2_plot

head(falo_rm)

falo_freq_1 <- falo_rm %>% 
  select(session, planner)

falo_freq_1_plot <- ggplot(falo_freq_1, aes(session, planner)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 10),
                     breaks = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Weekly Assignments Entered into Calendar",
       title = "Frequency of Planner Use") 

falo_freq_1_plot

falo_help_1 <- falo_rm %>% 
  select(session, help_plan)

falo_planner_plot <- ggplot(falo_help_1, aes(session, help_plan)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Perceived Helpfulness",
       title = "Perceived Helpfulness of Tracking Assignments in Planner",
       caption = "1 = Not Helpful at All\n 2 = Not Helpful\n 3 = Somewhat Helpful\n 4 = Helpful\n 5 = Very Helpful") 

falo_planner_plot


falo_freq_2 <- falo_rm %>% 
  select(session, num_days)

falo_freq_2_plot <- ggplot(falo_freq_2, aes(session, num_days)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 7),
                     breaks = c(0, 1, 2, 3, 4, 5, 6, 7)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of Days Per Week Using Time Block Strategy",
       title = "Frequency of Time Block Strategy Use") 

falo_freq_2_plot

falo_help_2 <- falo_rm %>% 
  select(session, help_block)

falo_block_plot <- ggplot(falo_help_2, aes(session, help_block)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 5),
                     breaks = c(1, 2, 3, 4, 5)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Perceived Helpfulness",
       title = "Perceived Helpfulness of Time Block Strategy",
       caption = "1 = Not Helpful at All\n 2 = Not Helpful\n 3 = Somewhat Helpful\n 4 = Helpful\n 5 = Very Helpful") 

falo_block_plot
```


```{r falo status 1, include=TRUE}
falo_status_1_plot
```

### Phone Strategy Use

```{r falo phone graph, include=TRUE, fig.align="left"}
phone_falo_graph
```

### Perceived Effectiveness 

```{r phone strategy helpfulness, include=TRUE, fig.align="left"}
falo_effect_graph
```

### Status Tracking 2

```{r falo status tracking 2, include=TRUE}
falo_status_2_plot
```

### Planner Use
```{r falo planner use, include=TRUE}
falo_freq_1_plot
```

### Planner Helpfulness
```{r falo planner helpfulness, include=TRUE}
falo_planner_plot
```

### Time Block Use
```{r falo time block use, include=TRUE}
falo_freq_2_plot
```

### Planner Helpfulness
```{r falo time block helpfulness, include=TRUE}
falo_block_plot
```


# DRKAT Outcome 

Column {.tabset data-width=650}
-----------------------------------------------------------------------

```{r drkat measures data organization, include=FALSE}
head(outcome)


drkat_brief_2 <- brief_data %>% 
  filter(client == "DRKAT") %>% 
  select(client, 22, 23) %>% 
  rename("Working Memory Pre" = working_memory_pre_self,
         "Working Memory Post" = working_memory_post_self) %>% 
  pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )

drkat <- outcome %>% 
  filter(client == "DRKAT")

brief_drkat <- drkat %>% 
  select(1, 16, 17, 20, 21, 32, 33) %>% 
  rename("Pre Global" = brief_global_pre_self,
         "Post Global" = brief_global_post_self,
         "Pre BRI" = brief_bri_pre_self,
         "Post BRI" = brief_bri_post_self,
         "Pre MI" = brief_mi_pre_self,
         "Post MI" = brief_mi_post_self) %>% 
  pivot_longer(
    cols = c(2:7),
    names_to = "measure",
    values_to = "score"
  )

drkat_brief_graph <- c("Working Memory Pre", "Working Memory Post")

class_drkat <- drkat %>% 
  select(client, class_total_pre, class_total_post) %>% 
  rename("Pre Score" = class_total_pre,
         "Post Score" = class_total_post) %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )


pcss_drkat <- drkat %>% 
  select(1, c(6:13)) %>% 
  rename("Feeling Slow Pre" = pcss_pre_feeling_slow,
         "Feeling Slow Post" = pcss_post_feeling_slow,
         "Feeling Foggy Pre" = pcss_pre_feeling_foggy,
         "Feeling Foggy Post" = pcss_post_feeling_foggy,
         "Difficulty Concentrating Pre" = pcss_pre_difficulty_concentrating,
         "Difficulty Concentrating Post" = pcss_post_difficulty_concentrating, 
         "Difficulty Remembering Pre" = pcss_pre_difficulty_remembering,
         "Difficulty Remembering Post" = pcss_post_difficulty_remembering) %>% 
  pivot_longer(
    cols = c(2:9),
    names_to = "measure",
    values_to = "score"
  )

hit_drkat <- drkat %>% 
  select(client, hit_pre, hit_post) %>% 
  rename("Pre Score" = hit_pre,
         "Post Score" = hit_post) %>% 
   pivot_longer(
    cols = c(2:3),
    names_to = "measure",
    values_to = "score"
  )
```

```{r drkat plots, include=FALSE}

drkat_brief_plot <- ggplot(drkat_brief_2, aes(measure, score)) +
  geom_hline(yintercept = 65, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = drkat_brief_graph) +
  scale_y_continuous(limits = c(0, 100),
                     breaks = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        plot.subtitle = element_text(color = "black", size = 10, face = "bold"),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "T-score",
       title = "BRIEF Scores",
       subtitle = "Working Memory Scale",
       caption = "T-scores Above 65 are Clinically Significant") 

drkat_brief_plot

drkat_class_plot <- ggplot(class_drkat, aes(measure, score)) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = class_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) +
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "CLASS Scores") 

drkat_class_plot


drkat_pcss_plot <- ggplot(pcss_drkat, aes(measure, score)) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = pcss_positions) +
  scale_y_continuous(limits = c(0, 6),
                     breaks = c(0, 1, 2, 3, 4, 5, 6)) + 
  geom_text(aes(measure, score, label = score),
            nudge_y = -1,
            color = "white") +
  coord_flip() +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "PCSS Results",
       subtitle = "Cognitive Symptoms",
       caption = "0 = No Symptoms\n 3 = Moderate Symptoms\n 6 = Severe Symptoms") 

drkat_pcss_plot

drkat_hit_plot <- ggplot(hit_drkat, aes(measure, score)) +
  geom_hline(yintercept = 50, 
             linetype = "dashed",
             size = 1) +
  geom_col(fill = "blue", 
           alpha = 0.7) +
  scale_x_discrete(limits = hit_positions) +
  scale_y_continuous(limits = c(0, 60),
                     breaks = c(10, 20, 30, 40, 50, 60)) + 
  geom_text(aes(measure, score, label = score),
            nudge_y = -3,
            color = "white") +
  theme(panel.grid.major.y = element_blank(),
        panel.grid.minor.x = element_blank(),
        panel.grid.major.x = element_line(color = "gray80")) +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10),
        plot.caption = element_text(size = 10)) +
  labs(x = "",
       y = "Score",
       title = "HIT Results",
       caption = "Scores of 50 or Greater Suggest Headaches Significantly Impact Daily Functioning") 

drkat_hit_plot
```

### BRIEF 
```{r drkat brief, include=TRUE, fig.width=6}
drkat_brief_plot
```

### CLASS

```{r drkat class, include=TRUE, fig.width=6}
drkat_class_plot
```

### PCSS

```{r drkat pcss, include=TRUE}
drkat_pcss_plot
```

### HIT

```{r drkat hit, include=TRUE}
drkat_hit_plot
```

Column {data-width=350}
-----------------------------------------------------------------------

### Client Demographics

```{r, include=FALSE}
head(outcome)

demo_drkat <- outcome %>% 
  filter(client == "DRKAT") %>% 
  select(2:5)
  
head(demo_drkat)

drkat_table <- demo_drkat %>% 
  gt() %>% 
  cols_label(sex = "Sex",
             age = "Age",
             prev_mtbi = "Prior Concussions",
             hx_depression = "History of Depression or Anxiety") %>% 
  cols_align(align = "center", columns = vars(sex, age, prev_mtbi, hx_depression)) %>% 
  tab_header(title = "Client Demographics")
  
drkat_table
```

```{r drkat table, include=TRUE}
drkat_table
```


# DRKAT Repeated

Column {.tabset data-width=650}
-----------------------------------------------------------------------

### Status Tracking

```{r repeated measures drkat data cleaning, include=FALSE}

drkat_track <- rm_drkat %>% 
  select(session, status)

drkat_status_plot <- ggplot(drkat_track, aes(session, status)) +
  geom_line() +
  geom_point(size = 2) +
  scale_x_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  scale_y_continuous(limits = c(0, 10),
                     breaks = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) +
  theme_classic() +
  theme(plot.title = element_text(color = "black", size = 12, face = "bold", hjust = 0.5),
        axis.text = element_text(size = 10),
        axis.title=element_text(size=10),
        strip.text = element_text(size = 10)) +
  labs(x = "Session",
       y = "Number of House Chores Completed per Week",
       title = "Status Tracking Goal") 

drkat_status_plot


```


```{r drkat status, include=TRUE}
drkat_status_plot
```